package com.app.controller;

import com.app.common.BaseVo;
import com.app.entity.Popular;
import com.app.service.IPopularService;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @autor xiaoyu.fang
 * @date 2019/10/11 15:28
 */
@RestController
@RequestMapping("/popular")
public class PopularController {

    @Autowired
    private IPopularService IPopularService;

    @PostMapping("/insert")
    public BaseVo insert(@RequestBody Popular popular) {
        IPopularService.insert(popular);
        return new BaseVo();
    }

    @PostMapping("/delete")
    public BaseVo delete(@RequestParam(value = "id") ObjectId id) {
        IPopularService.delete(id);
        return new BaseVo();
    }

    @GetMapping("/query")
    public BaseVo query() {
        return new BaseVo(IPopularService.query());
    }
}
